<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

//前台
Route::get('/', function(){
    return redirect('home/index/index');
});

Route::group(['prefix' => 'home'], function()
{
    Route::get('login/index', ['uses'=>'\App\Http\Controllers\Home\LoginController@index']);
    Route::get('login/login', ['uses'=>'\App\Http\Controllers\Home\LoginController@login']);
    Route::get('login/logout', function(){
        \Illuminate\Support\Facades\Session::forget('home');
        return redirect('home/login/index');
    });
    Route::get('index/index', ['uses'=>'\App\Http\Controllers\Home\IndexController@index']);
    Route::get('index/renew', ['uses'=>'\App\Http\Controllers\Home\IndexController@renew']);
    Route::get('index/qrcode', function(\Illuminate\Http\Request $request) {
        return response(\App\Http\Controllers\QRcodeController::qrCode(urldecode($request->input('url')), $request->input('size', '120'), $request->input('padding', 5), $request->input('font_size', 12), $request->input('label_text', '万兆通信')), 200)->header('content-type', 'image/png');
    });
    Route::get('person/index', ['uses'=>'\App\Http\Controllers\Home\PersonController@index']);
    Route::any('pay/notify', ['uses'=>'\App\Http\Controllers\Home\PayController@notify']);
    Route::any('pay/result/{id}', ['uses'=>'\App\Http\Controllers\Home\PayController@result']);
    Route::group(['middleware'=>'auth.home'],function(){
        Route::any('index/productshow/', ['uses'=>'\App\Http\Controllers\Home\IndexController@productShow']);
        Route::get('index/product/', ['uses'=>'\App\Http\Controllers\Home\IndexController@product']);
        Route::get('index/plot/', ['uses'=>'\App\Http\Controllers\Home\IndexController@plot']);
        Route::any('index/order/{orderid}', ['uses'=>'\App\Http\Controllers\Home\IndexController@orderPay']);
        Route::any('index/dorder/', ['uses'=>'\App\Http\Controllers\Home\IndexController@dorderPay']);
        Route::get('person/myqrcode', ['uses'=>'\App\Http\Controllers\Home\PersonController@myQrCode']);
        Route::any('person/setinfo', ['uses'=>'\App\Http\Controllers\Home\PersonController@setInfo']);
        Route::get('person/myproxy', ['uses'=>'\App\Http\Controllers\Home\PersonController@myPorxy']);
        Route::get('person/primagency/{id}', ['uses'=>'\App\Http\Controllers\Home\PersonController@primAgency']);
        Route::get('person/secagency/{id}', ['uses'=>'\App\Http\Controllers\Home\PersonController@secAgency']);
        Route::get('person/myorder', ['uses'=>'\App\Http\Controllers\Home\PersonController@myOrder']);
        Route::get('person/orderdetail/{id}', ['uses'=>'\App\Http\Controllers\Home\PersonController@orderDetail']);
        Route::get('person/myorderdetail/{id}', ['uses'=>'\App\Http\Controllers\Home\PersonController@myOrderDetail']);
        Route::get('person/mypayagent', ['uses'=>'\App\Http\Controllers\Home\PersonController@myPayagent']);
        Route::get('person/myaccount', ['uses'=>'\App\Http\Controllers\Home\PersonController@myAccount']);
        Route::get('person/pushmoney', ['uses'=>'\App\Http\Controllers\Home\PersonController@pushMoney']);
        Route::get('person/apply', ['uses'=>'\App\Http\Controllers\Home\PersonController@apply']);
        Route::get('person/closeorder/{id}', ['uses'=>'\App\Http\Controllers\Home\PersonController@closeOrder']);
        Route::get('person/editorder/{id?}', ['uses'=>'\App\Http\Controllers\Home\PersonController@editOrder']); 
        Route::get('pay/index/{id}', ['uses'=>'\App\Http\Controllers\Home\PayController@index']);
    });
    
});
/**
 * 微信
 */
Route::group(['prefix' => 'wechat'], function(){
    Route::any('index/index', ['uses'=>'\App\Http\Controllers\Wechat\IndexController@index']);
    Route::any('index/getuinfo', ['uses'=>'\App\Http\Controllers\Wechat\IndexController@getUinfo']);
});

//后台
Route::group(['prefix' => 'admin'], function(){
    Route::any('login/index',['uses' => '\App\Http\Controllers\Admin\LoginController@index']);
    Route::get('login/logout',['uses' => '\App\Http\Controllers\Admin\LoginController@logout']);
    Route::group(['middleware' => 'auth.admin'], function(){
        //商品
        Route::get('product/index', '\App\Http\Controllers\Admin\ProductController@index');
        Route::any('product/edit/{id}/{status?}', '\App\Http\Controllers\Admin\ProductController@edit')->where(['id' => '[0-9]+', 'status' => '0']);
        Route::any('product/add', '\App\Http\Controllers\Admin\ProductController@add');
        //小区
        Route::get('plot/index', '\App\Http\Controllers\Admin\PlotController@index');
        Route::any('plot/edit/{id}/{status?}', '\App\Http\Controllers\Admin\PlotController@edit');
        Route::any('plot/add', '\App\Http\Controllers\Admin\PlotController@add');
        //银行
        Route::get('bank/index', '\App\Http\Controllers\Admin\BankController@index');
        Route::any('bank/edit/{id}/{status?}', '\App\Http\Controllers\Admin\BankController@edit')->where(['id' => '[0-9]+', 'status' => '0']);
        Route::any('bank/add', '\App\Http\Controllers\Admin\BankController@add');
        //订单
        Route::get('order/index', '\App\Http\Controllers\Admin\OrderController@index');
        Route::get('order/find', '\App\Http\Controllers\Admin\OrderController@findOrder');
        Route::any('order/edit/{id}/{status?}', '\App\Http\Controllers\Admin\OrderController@edit')->where(['id' => '[0-9]+', 'status' => '[0234]']);
        Route::get('order/del/{id}', '\App\Http\Controllers\Admin\OrderController@del')->where(['id' => '[0-9]+']);
        Route::get('order/report', '\App\Http\Controllers\Admin\OrderController@report');
        //提现
        Route::get('account/index', '\App\Http\Controllers\Admin\AccountController@index');
        Route::any('account/edit/{id}/{status?}', '\App\Http\Controllers\Admin\AccountController@edit')->where(['id' => '[0-9]+', 'status' => '[23]']);
        //用户
        Route::get('user/index', '\App\Http\Controllers\Admin\UserController@index');
        Route::get('user/edit/{id}/{status}', '\App\Http\Controllers\Admin\UserController@edit')->where(['id' => '[0-9]+', 'status' => '[01]']);
        Route::get('user/editzw/{id}/{status}', '\App\Http\Controllers\Admin\UserController@editzw')->where(['id' => '[0-9]+', 'status' => '[01]']);
        Route::get('user/deluser/{id}', '\App\Http\Controllers\Admin\UserController@delUser')->where(['id' => '[0-9]+']);
        //分成比例
        Route::get('pushmoney/index', '\App\Http\Controllers\Admin\PushmoneyController@index');
        Route::any('pushmoney/edit/{id}', '\App\Http\Controllers\Admin\PushmoneyController@edit')->where(['id' => '[0-9]+']);
        //产品分类信息
        Route::get('pcate/index', '\App\Http\Controllers\Admin\PcateController@index');
        Route::any('pcate/edit/{id}/{status?}', '\App\Http\Controllers\Admin\PcateController@edit')->where(['id' => '[0-9]+']);
        Route::any('pcate/add', '\App\Http\Controllers\Admin\PcateController@add');
        //地区信息
        Route::get('area/index', '\App\Http\Controllers\Admin\AreaController@index');
        Route::any('area/edit/{id}/{status?}', '\App\Http\Controllers\Admin\AreaController@edit')->where(['id' => '[0-9]+']);
        Route::any('area/add', '\App\Http\Controllers\Admin\AreaController@add');
        //小区优惠信息
        Route::get('plotfav/index', '\App\Http\Controllers\Admin\PlotfavController@index');
        Route::any('plotfav/edit/{id}/{status?}', '\App\Http\Controllers\Admin\PlotfavController@edit')->where(['id' => '[0-9]+']);
        Route::any('plotfav/add', '\App\Http\Controllers\Admin\PlotfavController@add');
        Route::any('plotfav/ppinfo/{aid}', '\App\Http\Controllers\Admin\PlotfavController@ppInfo');
        
        //派单管理
        Route::get('jobs/index', '\App\Http\Controllers\Admin\JobsController@index');
        Route::any('jobs/add', '\App\Http\Controllers\Admin\JobsController@add');
        Route::get('jobs/plotiper', '\App\Http\Controllers\Admin\JobsController@plotiper');
        Route::get('jobs/changereciver/{id}/{plotid}', '\App\Http\Controllers\Admin\JobsController@changeReciver');
        //公告管理
        Route::get('notice/index', '\App\Http\Controllers\Admin\NoticeController@index');
        Route::any('notice/add', '\App\Http\Controllers\Admin\NoticeController@add');
        Route::get('notice/del/{id}', '\App\Http\Controllers\Admin\NoticeController@del')->where(['id'=>'[0-9]+']);
        //装维人员管理
        Route::get('instper/index', '\App\Http\Controllers\Admin\InstpersonController@index');
        Route::any('instper/add', '\App\Http\Controllers\Admin\InstpersonController@add');
        Route::any('instper/modplot/{iperid}', '\App\Http\Controllers\Admin\InstpersonController@modPlot')->where(['iperid'=>'[0-9]+']);
        //反馈原因管理
        Route::get('cause/index', '\App\Http\Controllers\Admin\CauseController@index');
        Route::any('cause/add', '\App\Http\Controllers\Admin\CauseController@add');
        Route::get('cause/del/{id}', '\App\Http\Controllers\Admin\CauseController@del')->where(['id'=>'[0-9]+']);
    });
});
/**
 * 派单系统
 */
Route::group(["prefix"=>'job'], function(){
    Route::any('login/index',['uses' => '\App\Http\Controllers\Job\LoginController@index']);
    Route::get('login/logout',['uses' => '\App\Http\Controllers\Job\LoginController@logout']);
    Route::group(['middleware' => 'auth.job'], function(){
        Route::get('index/index', ['uses'=> '\App\Http\Controllers\Job\IndexController@index']);
        Route::get('index/myjob', ['uses'=> '\App\Http\Controllers\Job\IndexController@myJob']);
        Route::get('index/jobdetail/{id}', ['uses'=> '\App\Http\Controllers\Job\IndexController@jobDetail']);
        Route::any('index/tick/{id}', ['uses'=> '\App\Http\Controllers\Job\IndexController@tick']);
        Route::any('notice/index/', ['uses'=> '\App\Http\Controllers\Job\IndexController@notice']);
    });
});
